package com.ityibai.bootstrap.service.impl;

import com.github.pagehelper.PageHelper;
import com.ityibai.bootstrap.entity.User;
import com.ityibai.bootstrap.mapper.UserMapper;
import com.ityibai.bootstrap.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;

/**
 * Created by YinLin on 18/5/22.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int save(User user) {
        return userMapper.insert(user);
    }

    @Override
    public List<User> findAll() {
        PageHelper.startPage(0, new Random().nextInt(5) + 1);
        return userMapper.selectAll();
    }
}
